package com.hspedu.tankgame4;

import java.util.Vector;

/**
 * @author DL5O
 * @version 1.0
 */
public class Tank {
    private int x;//坦克的横坐标
    private int y;//坦克的纵坐标
    private int direct;//坦克的方向
    private int type;//坦克的种类
    private int speed;//坦克的速度
    boolean isLive = true;
    Vector<Shot> shots  = new Vector<>();

    public Tank(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Tank(int x, int y, int speed) {
        this.x = x;
        this.y = y;
        this.speed = speed;
    }

    public Tank(int x, int y, int type, int speed) {
        this.x = x;
        this.y = y;
        this.type = type;
        this.speed = speed;
    }

    public void shotTank(){
        Shot shot = null;//表示一个射击行为
        //创建Shot 对象，根据当前Hero对象的位置和方向来创建Shot
        switch (getDirect()) {//得到或这个Hero 玩家坦克的方向
            case 0://向上
                shot = new Shot(x + 20, y, 0);
                break;
            case 1://向右
                shot = new Shot(x + 60, y + 20, 1);
                break;
            case 2://向下
                shot = new Shot(x + 20, y + 60, 2);
                break;
            case 3://向左
                shot = new Shot(x, y+ 20, 3);
                break;
            default:
                break;
        }
        shots.add(shot);
        new Thread(shot).start();
    }
    //上下左右移动方法
    public void moveUp() {
        y = y - speed;
    }

    public void moveDown() {
        y = y + speed;
    }

    public void moveRight(){
        x = x + speed;
    }

    public void moveLeft(){
        x = x - speed;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getDirect() {
        return direct;
    }

    public void setDirect(int direct) {
        this.direct = direct;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }
}
